package chapter9.demo;

/**
 * @Author juzipi
 * @Date 2021/6/21 15:19
 * @Info
 */
public class ValueTransferTest1 {
    public static void main(String[] args) {
        Data data = new Data();
        data.m = 10;
        data.n = 20;
        System.out.println(data);

//        int temp = data.m;
//        data.m = data.n;
//        data.n = temp;
//        System.out.println(data);

        ValueTransferTest1 valueTransferTest1 = new ValueTransferTest1();
        valueTransferTest1.swap(data);
        System.out.println(data);
    }

    public void swap(Data data){
        int temp = data.m;
        data.m = data.n;
        data.n = temp;
    }

}

class Data{

    int m;
    int n;

    @Override
    public String toString() {
        return "Data{" +
                "m=" + m +
                ", n=" + n +
                '}';
    }
}
